#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,a[200009],c[200009];
int work(){
    int lst[2]={-1,-1},ans=0;
    for(int i=1;i<=n;i++){
        if(lst[c[i]]>0){
            if(a[lst[c[i]]]==a[i]){
                ans+=a[i];
            }
        }
        lst[c[i]]=i;
    }
    return ans;
}
void solve(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans=0;
    for(int i=0;i<(1ll<<n);i++){
        int j=i,id=0;
        while(id<n){
            id++;
            if(j&1)c[id]=0;
            else c[id]=1;
            j>>=1;
        }
        ans=max(ans,work());
    }
    cout<<ans<<"\n";
}
signed main(){
freopen("color.in","r",stdin);
freopen("color.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
        solve();
    }
}
